/**
 * @author mike
 * @time 2017/05/31
 * @desc webpack打包工具
 */

var path = require("path");
var webpack = require('webpack');
var ExtractTextPlugins = require('extract-text-webpack-plugin');

var extractCss = new ExtractTextPlugins("css/[name].css");//这里的参数是配置编译后的css路径和文件名,相对于output里的path选项

module.exports = {
    entry: {
        main: [
            './app/app'
        ]
    },
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: "bundles.js"
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        extractCss
    ],
    module: {
        loaders: [
            { 
            	test: /\.js$/, 
            	exclude: /node_modules/, 
            	loader: "babel-loader" 
            },
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                loader: 'babel-loader',
                query: {
                    presets: ['es2015', 'react']
                }
            }, 
            {
               test: /\.scss$/,
               loader: extractCss.extract(['css','sass'])
            }
        ]
    },
    resolve: {
    	root: path.resolve('app'),
    	modulesDirectories: ["node_modules"],
        extensions: ['', '.js', '.jsx','.scss'],
        alias: {
          //脚本文件引用路径简写
        }
    },
    sourcemap: true 
};
